﻿using LxBasic;
using System;

namespace LxCore
{
    public class CostTimeStatistic : StatisticBase
    {
        bool isEmpty = true;
        DateTime StartTime = DateTime.Now;
        public override AccumulationDouble RunReport(UserMonitor userMonitor, bool isConsole = false)
        {
            if (isEmpty)
            {
                StartTime = DateTime.Now;
                isEmpty = false;
                return AccumulationDouble.Empty;
            }
            else
            {
                TimeSpan span = DateTime.Now - StartTime;
                return new AccumulationDouble(span.TotalSeconds);
            }
        }
    }
}
//public override void GlobalIni()
//{
//    if (IsGlobalValid)
//    {
//        TimeSpan span = DateTime.Now - StartTime;
//        LocalResult = span.TotalSeconds;
//        GlobalResult += LocalResult;
//    }
//    else
//    {
//        IsGlobalValid = true;
//        StartTime = DateTime.Now;
//        GlobalResult = 0;
//    }
//}
//public override void RunStatistic(bool isConsole)
//{
//    if (InMonitor.IsCurrentExist)
//    {
//        DateTime current = DateTime.Now;
//        TimeSpan span = current.Subtract(StartTime);
//        InMonitor.CurrentResult = LocalResult = span.TotalSeconds;
//    }
//    else
//    {
//        InMonitor.CurrentResult = LocalResult = 0;
//        StartTime = DateTime.Now;
//        InMonitor.IsCurrentExist = true;
//    }
//}
